# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer:
pkgname=ws
pkgver=9.9.0
pkgrel=1
pkgdesc="websocket and http client and server command line swiss army"
options="!check"
url="https://github.com/machinezone/IXWebSocket"
arch="all"
license="BSD-3-Clause"
makedepends="cmake openssl1.1-compat-dev zlib-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/machinezone/IXWebSocket/archive/v$pkgver.tar.gz"
builddir="$srcdir/IXWebSocket-$pkgver"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build . \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
		-DUSE_TLS=1 \
		-DUSE_WS=1 \
		$CMAKE_CROSSOPTS
	make -C build
}

package() {
	make -C build DESTDIR="$pkgdir" install

	# We don't care about anything but the ws binary
	rm -rf "$pkgdir"/usr/include
	rm -rf "$pkgdir"/usr/lib
}
sha512sums="1d4ca7598d7ba1f034a9a078a621401753453748a58c06eb59d7721d2fc1db5d891248660731116e21803df39f5b6f0f43e3781f6b02c65c580e0220a94b2c82  ws-9.9.0.tar.gz"
